<script type="text/javascript">
var form_validation = true;

function submit_rrserver_update() {
    var rrserver_address = $("#rrserver_update_modal").find("#rrserver_address_cr");
    var rrserver_port = $("#rrserver_update_modal").find("#rrserver_port_cr");
    var bValid = true;
    bValid = bValid && checkipRegexp(rrserver_address, /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/i, "无效的IP地址.");
    bValid = bValid && checkRegexp_num(rrserver_port, /^[0-9]+$/i, "端口必须为大于0的整数");
    bValid = bValid && checkPort(rrserver_port, '端口范围为 1 ～ 65535。');
    if (bValid) {
        if (form_validation) {
            form_validation = false;
            var $submitBtn = $('.modal-footer').find('.btn-blue');
            $submitBtn.html('<i class="fa fa-spinner fa-spin" style="margin:3px 6px;"></i>');
            $('.rtn-tip').slideUp('fast');
            $.post("/rrserver_update", {
                    "id": "{{rrserver.id}}",
                    "address": rrserver_address.val(),
                    "port": rrserver_port.val(),
                },
                function(data) {
                    if (data.reply.is_success) {
                        angular.element('#rrserver_controller').scope().close();
                        $('#rrserver_table').trigger("reloadGrid")
                    } else {
                        error = data.reply.error;
                        $('.rtn-tip').text(error).slideDown('fast');
                        $submitBtn.html(SelfTranslate("[[ 'label ok'|translate ]]"));
                        form_validation = true;
                    }
                });
        }
    }
}
$(function() {
    var obj = {
        'address':'输入ip地址。',
        'port':'端口范围为 1 ～ 65535。',
    }
    bindMouseEvent('#rrserver_update_modal', obj);
    /* 为小图标绑定鼠标移入移出事件结束 */
});
</script>
<div class="modal-header">
    <h3>编辑站点</h3>
</div>
<div class="modal-body modal-body-height" id="rrserver_update_modal">
    <div class="user-create-box">
        <div class="rtn-tip"></div>
        <table class="super-info" style="margin-top:0; ">
            <tr>
                <td>
                    <label>IP</label><a>*</a>
                </td>
                <td>
                    <input id="rrserver_address_cr" name="rrserver_address_cr" size="25" type="text" value="{{rrserver.address}}" />
                    <i class="fa fa-question-circle" itype="address"></i>
                </td>
                <td>
                    <label>端口</label><a>*</a>
                </td>
                <td>
                    <input id="rrserver_port_cr" name="rrserver_port_cr" size="25" type="text" value="{{rrserver.port}}" />
                    <i class="fa fa-question-circle" itype="port"></i>
                </td>
            </tr>
        </table>
    </div>
    <div class="error-tip">
        <p></p>
        <span></span></div>
    <div class="tip">
        <p></p>
        <span></span>
    </div>
</div>
<div class="modal-footer">
    <button class="btn btn-blue" ng-click="update()">[[ 'label ok'|translate ]]</button>
    <button class="btn btn-white" ng-click="cancel()">[[ 'label cancel'|translate ]]</button>
</div>
